package cn.com.headfree.mouldshow.dao.impl;

import cn.com.headfree.entity.TWorkExpInfo;
import cn.com.headfree.mouldshow.dao.TWorkExpInfoDao;
import cn.com.headfree.vo.simple.WorkExpInfoVo;
import com.gta.edu.sdk.base.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("/tWorkExpInfoDao")
public class TWorkExpInfoDaoImpl extends BaseDaoImpl<TWorkExpInfo> implements TWorkExpInfoDao {


    @Override
    public List<WorkExpInfoVo> findByBaseorgId(String deptId) throws Exception{
        Object[] params = new Object[1];
        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,t.start_date,t.end_date,t.company,t.dept,t.post,t.rank,u.`NAME` as user_name,t.job_content,t.post_type from t_work_exp_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on t.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.start_date DESC");
//        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,t.start_date,t.end_date,t.company,t.dept,t.post,GET_DIC('DutyLevel',t.rank) as rank,u.`NAME` as user_name,t.job_content,GET_DIC('PostCategory',t.post_type) as post_type from t_work_exp_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on t.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.start_date DESC");
//        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,t.start_date,DATE_FORMAT(t.start_date,'%Y-%m-%d %H:%i:%s') as start_date_str,t.end_date,DATE_FORMAT(t.end_date,'%Y-%m-%d %H:%i:%s') as end_date_str,t.company,t.dept,t.post,GET_DIC('DutyLevel',t.rank) as rank,u.`NAME` as user_name,t.job_content,GET_DIC('PostCategory',t.post_type) as post_type from t_work_exp_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on t.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.start_date DESC");
//        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,t.start_date,DATE_FORMAT(t.start_date,'%Y-%m-%d %H:%i:%s') as start_date_str,t.end_date,DATE_FORMAT(t.end_date,'%Y-%m-%d %H:%i:%s') as end_date_str,t.company,t.dept,t.post,GET_DIC('DutyLevel',t.rank) as rank,u.xb_name as user_name,t.job_content,GET_DIC('PostCategory',t.post_type) as post_type from t_work_exp_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id INNER JOIN t_isc_user_tmp u on t.erp_no=u.hr_erp WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.start_date DESC");
        params[0] = "%"+deptId+"%";
        return this.findAllBySQL(WorkExpInfoVo.class, sql.toString(), null, false, params);
    }
}
